package jjn.round2;

import commons.TreeNode;

/**
 * @author Jjn
 * @since 2023/6/8 18:30
 */
public class LeetCode112_PathSum {
    
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) {
            return false;
        }
        if (root.left == null && root.right == null) {
            return targetSum - root.val == 0;
        }
        return hasPathSum(root.left, targetSum - root.val)
                || hasPathSum(root.right, targetSum - root.val);
    }
}
